<layout name="layout"/>

<!-- 搜索 -->
<div class="form-div search_form_div">
    <form action="__ACTION__" method="GET" name="search_form">
        <p>
            分类名称：
            <input type="text" name="name" size="30" value="<?php echo I('get.name'); ?>"/>
        </p>
        <p><input type="submit" value=" 搜索 " class="button"/></p>
    </form>
</div>
<!--添加短连接按钮-->
<div class="form-div search_form_div" style="float: right; margin-right: 100px;">

    <p><input id="goadd" type="button" value=" 添加视频分类 " class="button"/></p>

</div>
<!-- 列表 -->
<div class="list-div" id="listDiv">
    <table class="table table-hover text-center">
        <tr>
            <th>ID</th>
            <th>分类名称</th>
            <th width="500">操作</th>
        </tr>
        <?php foreach ($data as $k => $v): ?>
        <tr class="tron">
            <td><?php echo $v['id']; ?></td>
            <td><?php echo $v['name']; ?></td>
            <td align="center">
                <a href="<?php echo U('edit?id='.$v['id'].'&p='.I('get.p')); ?>" title="编辑"
                   class="button border-main" style="cursor: pointer"><span class="icon-edit"></span>编辑</a>
                <a class="button border-red del" style="cursor: pointer" onclick="del(this)"
                   url="<?php echo U('delete?id='.$v['id'].'&p='.I('get.p')); ?>"
                   title="移除"> <span class="icon-trash-o"></span>移除</a>
            </td>
        </tr>
        <?php endforeach; ?>
        <?php if(preg_match('/\d/', $page)): ?>
        <tr>
            <td colspan="10">
                <?php echo $page; ?>
            </td>
        </tr>
        <?php endif; ?>
    </table>
</div>

<script>

    function del(obj) {
        if (confirm('确认删除吗？')) {
            $.get($(obj).attr('url'), function (res) {
                alert(res.info);
                location.href = res.url;
            })
        }
    }

    $("#goadd").click(function () {
        location.href = "<?php echo U('sptype/add')?>";
    })
</script>

